<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<c:set var="buttons">
    <input type="button" style="margin-right: 5px"   onclick="f_batchPay()" value="<fmt:message key="button.batchPay"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_delete()" value="<fmt:message key="button.delete"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_cancel()" value="<fmt:message key="button.cancel"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_save()" value="<fmt:message key="button.save"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_query()" value="<fmt:message key="button.query"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_excel()" value="<fmt:message key="button.excel"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_exportPhotoes()" value="<fmt:message key="button.exportPhotoes"/>"/>
<c:if test='${not empty model.parentId}'>
    <input type="button" style="margin-right: 5px"   onclick="f_back()" value="<fmt:message key="button.back"/>"/>
</c:if>
</c:set>
<div id='toolbar' style="display:none">
<c:out value="${buttons}" escapeXml="false"/>
</div>
<div id="parameter_form" align=center></div> 
<script>
Ext.onReady(globalScope._ready);

<c:if test='${not empty model.parentId}'>
function f_back(){
   globalScope._back();
}
</c:if>

var year="<c:out value='${model.currentYear}'/>";
var semester="<c:out value='${model.currentSemester}'/>";
var examType="";
var tname="<c:out value='${model.tableName}'/>";
Ext.onReady(function(){
  Ext.get('title').dom.style.display='none';
   var currentYear="<c:out value='${model.currentYear}'/>";
   var currentSemester="<c:out value='${model.currentSemester}'/>";
   var schoolYear=Ext.decode('<c:out value="${model.schoolYear}" escapeXml="false"/>');
   var yearArray=[['','请选择']];
   Ext.each(schoolYear,function(r){
     var year=[r.CODE,r.NAME];
     yearArray.push(year);
   });
   var yearStore={
     'fields':['value','text'],
     data:yearArray
   };
   
   var schoolSemester=Ext.decode('<c:out value="${model.schoolSemester}" escapeXml="false"/>');
   var semesterArray=[['','请选择']];
   Ext.each(schoolSemester,function(r){
     var semester=[r.CODE,r.NAME];
     semesterArray.push(semester);
   });
   var semesterStore={
     'fields':['value','text'],
     data:semesterArray
   };
   
   var externalExamTypes=Ext.decode('<c:out value="${model.externalExamTypes}" escapeXml="false"/>');
   var examTypesArray=[['','请选择']];
   Ext.each(externalExamTypes,function(r){
     var examType=[r.CODE,r.NAME];
     examTypesArray.push(examType);
   });
   var examTypeStore={
     'fields':['value','text'],
     data:examTypesArray
   };
  
	var form = new Ext.form.FormPanel({
	 	  labelAlign:'right',
		  frame:true,
		  border:true,
		  height:40,
	      items:[{
	          layout:'column',
	          items:[{
		            layout:'form',
		            columnWidth:1/4,
	  		        items:[{
			            xtype:'combo',   
			            fieldLabel:'学年度',  
			            value:currentYear, 
			            store: new Ext.data.SimpleStore(yearStore),   
			            editable: false,   
			            hiddenName:'SCHOOL_YEAR',   
			            displayField:'text',   
			            valueField:'value',   
			            typeAhead:true,   
			            mode: 'local',   
			            triggerAction: 'all',   
			            emptyText:'请选择',   
			            selectOnFocus:true,   
			            resizable:true,   
			            allowBlank:false,   
			            anchor:'90%',
			            forceSelection:true ,
			            disabled :true          
		         }]
	         },{
		            layout:'form',
		            columnWidth:1/4,
	  		        items:[{
			            xtype:'combo',   
			            fieldLabel:'学期',   
			            value:currentSemester,
			            store: new Ext.data.SimpleStore(semesterStore),   
			            editable: false,   
			            hiddenName:'SCHOOL_SEMESTER',   
			            displayField:'text',   
			            valueField:'value',   
			            typeAhead:true,   
			            mode: 'local',   
			            triggerAction: 'all',   
			            emptyText:'请选择',   
			            selectOnFocus:true,   
			            resizable:true,   
			            allowBlank:false,   
			            anchor:'90%',
			            forceSelection:true ,
			            disabled :true          
 	  		        }]
	         
	         },{
		            layout:'form',
		            columnWidth:1/4,
	  		        items:[{
			            xtype:'combo',   
			            fieldLabel:'考试类型',   
			            store: new Ext.data.SimpleStore(examTypeStore),   
			            editable: false,   
			            hiddenName:'EXTERTERNAL_EXAM_TYPE',   
			            id:'_EXTERTERNAL_EXAM_TYPE',   
			            displayField:'text',   
			            valueField:'value',   
			            typeAhead:true,   
			            mode: 'local',   
			            triggerAction: 'all',   
			            emptyText:'请选择',   
			            selectOnFocus:true,   
			            resizable:true,   
			            allowBlank:false,   
			            anchor:'90%',
			            forceSelection:true           
	  		        }]
	         
	         }]
	   }]
	 });  
	
	form.render('parameter_form'); 
	
   var examTypeCombo=form.getForm().findField('_EXTERTERNAL_EXAM_TYPE');
   examTypeCombo.on('select',function(comboBox){
	    examType=comboBox.getValue();
	    globalScope._changeQuickCookie("SCHOOL_YEAR",currentYear);
	    globalScope._changeQuickCookie("SCHOOL_Semester",currentSemester);
	    globalScope._changeQuickCookie("EXAM_TYPE",examType);
	    globalScope._model({tableName:tname},function(responseText){
	        var htmlDiv=Ext.get("table_html").dom;
		    htmlDiv.innerHTML=responseText;
		    var htmlTable=Ext.get(tname);
		    globalScope.grid.get(tname).reloadData(htmlTable);	
		    globalScope.queryWin.get(tname).afterQuery(responseText);
	   },true);	
	}); 
  	  
});

function f_batchPay(){
	   var recs=globalScope.grid.get(tname).getSelectionModel().getSelections();
	   if(recs.length==0){
	     Ext.Msg.alert('WARNING',"请选择批量付费的学生!");
	     return;	
	   }
		Ext.Msg.confirm(jspVarHandler.fmt_label_info,"确定设置已选定学生为'已付费'吗?",function(btn){
	       var store=globalScope.grid.get(tname);
	   	   for(var i=0;i<recs.length;i++){
	   	     var r=recs[i];
	   	     r.set("STATUS","Y");
	   	   }
		 f_save();	   
		});	  
		 
	 

}

function f_exportPhotoes(){
  if(examType==""){
    alert("请选择报名类型！");
    return;
  }
  var url="<c:url value="/educational/examEntry/downloadImages.html"/>";
  var matrix=[["examType",examType]];
  var form=createForm(url,matrix);
  form.submit();
}

function f_excel(){
  globalScope._exportExcel();
//  globalScope._excel();
}

function f_add(tableName){
  globalScope._add(tableName);
}

function f_update(tableName){
  globalScope._update(tableName);
}

function f_delete(tableName){
  globalScope._delete(tableName);
} 

function f_cancel(tableName){
  globalScope._cancel(tableName);
}

function f_save(tableName,url){
  globalScope._simpleSave({url:'quick/quickJsonProcess.html',saveTableName:'T_EXTERNAL_EXAM_STUDENTS'});
//  globalScope._save(tableName,url);
}

function f_query(tableName){
    globalScope._query(tableName);
}
function f_gotoPage(pageNo,rowsOfPage,pageCount,rowCount,conditoin){
  globalScope._gotoPage({spanName:"g_pageSpan_<c:out value='${model.tableName}'/>",pageNo:pageNo,rowsOfPage:rowsOfPage,pageCount:pageCount,rowCount:rowCount,condition:conditoin,tableName:"<c:out value='${model.tableName}'/>"});
}

</script>  
    <c:if test="${not empty message}">
      <div  align="left" id="title" style="height:40px;vertical-align:bottom;bgcolor:blue;"><br><h3><STRONG><c:out value='${message}'/></STRONG></h3></div>
    </c:if>


  
